<?php

/**
 * @file: controllers/upuz.php
 * 
 * CRUD - Create, Read, Update, Delete
 * UPUZ - Ustvari, Preberi, Uredi, Zbriši
 *
 * @author roman
 */
class Upuz extends CI_Controller{
     
    public function __construct() {
        parent::__construct();
        $this->fields = $this->load->model('Crud');
    }

    public function index(){
        $this->read();
    }
    
    public function create(){
        if($this->input->post('submit')){
            $this->Crud->create();
        }
        $data['results']['fields'] = $this->Crud->fields;
        $this->load->view('crud_create',$data);
    }
    
    public function read(){
        $data['results'] = $this->Crud->read();
        $this->load->view('crud_read',$data);
    }
    
    public function update(){
        if($this->input->post('submit')){
            $this->Crud->update();
        }
        $id = $this->uri->segment(3);
        $data['results'] = $this->Crud->read($id);
        $this->load->view('crud_update',$data);
    }
    
    public function delete(){
        $this->Crud->delete();
    }
}
